/**
 * 
 */
package com.gosophia.conference.action.starting;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.conferenceManagement.common.ws.ConferenceQueryWebService;
import com.gosophia.conferenceManagement.starting.dto.ConferenceAppDetailDTO;
import com.gosophia.conferenceManagement.starting.dto.ConferenceApplicationDTO;
import com.gosophia.conferenceManagement.starting.dto.ConferenceStartingDTO;
import com.gosophia.oa.action.JudgeCurrentUndertaker;

/**
 * 功能：会议申请的详细
 * 
 * @author tianchunyu
 * @since 2011-3-22 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Controller("ConferenceApplicationDetailAction")
@Scope("prototype")
public class ConferenceApplicationDetailAction extends BaseSupportAction {
	private static final long serialVersionUID = 1L;
    private final String APPLICATION_FINALIZE="发起会议";
	@Autowired
	private ConferenceQueryWebService conferenceQueryWebService;
	private Long jobId;
    
	private ConferenceAppDetailDTO confAppDetailDTO;
	
	@Override
	public String _execute() throws Exception {
	    //不同页面： 申请发起页面   ： 发起页面  ： 根据jobtype【申请发起】   applicationJobData   
	    //       申请审批页面    ： 退回  提交下一人审批  【上一个申请的数据】 上一个job的数据   -》意见
	    //       申请修改           ：  applicationJobData       
	    //       申请取回页面    ： 取回前  操作后  applicationJobData      
	    //       申请批准定稿    ： 最新的申请数据 + 处理意见     【处理意见】
	    //       申请定稿            ： 最新的申请数据                           【最新数据】
	    //
	    confAppDetailDTO = conferenceQueryWebService
				.loadConfAppDetail(jobId);
	    if(APPLICATION_FINALIZE.equals(confAppDetailDTO.getJobType())){
	      ConferenceStartingDTO startingDTO =  conferenceQueryWebService.findConferenceMasterByJobId(jobId);
	      confAppDetailDTO.setConfAppDTO(loadAppInfo(startingDTO));
	    }
		return SUCCESS;
	}
 
	public Long getJobId() {
		return jobId;
	}

	public void setJobId(Long jobId) {
		this.jobId = jobId;
	}

    public ConferenceAppDetailDTO getConfAppDetailDTO() {
        return confAppDetailDTO;
    }

    public void setConfAppDetailDTO(ConferenceAppDetailDTO confAppDetailDTO) {
        this.confAppDetailDTO = confAppDetailDTO;
    }


    private ConferenceApplicationDTO loadAppInfo(ConferenceStartingDTO startingDTO){
        ConferenceApplicationDTO appDTO = new ConferenceApplicationDTO();
        appDTO.setPlanStartTime(startingDTO.getPlanStartTime());//计划开始时间
        appDTO.setMajorIssue(startingDTO.getMajorIssue());//会议议题
        appDTO.setMajorParticipators(startingDTO.getMajorParticipators());//主要参会人员
        appDTO.setApplicationInfo(startingDTO.getApplicationInfo());//申请说明信息
        appDTO.setConfernceUnderTakerName(startingDTO.getConfernceUnderTakerName());//会议承办人
        return appDTO;
    }
}
